﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KAImage.Algorithms;

namespace IPCPhotoEditor
{
    public partial class FormAutoAdjustOptions : Form
    {
        private int _defaultMode = 0;

        private AutoAdjusting _op = new AutoAdjusting();

        public FormAutoAdjustOptions(int mode)
        {
            _defaultMode = mode;
            InitializeComponent();
        }

        public FormAutoAdjustOptions()
        {
            InitializeComponent();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                double lowCut = Convert.ToDouble(textBoxShadow.Text);
                double highCut = Convert.ToDouble(textBoxHighLight.Text);
                _op.SaveConfig(lowCut, highCut);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void FormAutoAdjustOptions_Load(object sender, EventArgs e)
        {
            if (_defaultMode == 1)
            {
                radioButtonAutoLevel.Checked = true;
            }
            else
            {
                radioButtonAutoContrast.Checked = true;
            }
            textBoxHighLight.Text = _op.HighCut.ToString();
            textBoxShadow.Text = _op.LowCut.ToString();
        }
    }
}
